# Contributor: Michal Sidor <public+git@meekchopp.es>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=font-fira-code
_fontname=fira-code
pkgver=6.2
pkgrel=0
pkgdesc="Free monospaced font with programming ligatures"
url="https://github.com/tonsky/FiraCode"
arch="noarch"
license="OFL-1.1"
depends="fontconfig mkfontscale"
subpackages="$pkgname-vf"
source="https://github.com/tonsky/FiraCode/releases/download/$pkgver/Fira_Code_v$pkgver.zip
	fontconfig.conf
	"
builddir="$srcdir"
options="!check"  # no code to test

package() {
	install -D -m644 ttf/*.ttf -t "$pkgdir"/usr/share/fonts/$_fontname/

	cd "$pkgdir"
	_install_conf "$srcdir"/fontconfig.conf 61-$_fontname
}

vf() {
	pkgdesc="$pkgdesc (variable font)"

	cd "$builddir"
	install -D -m644 variable_ttf/*.ttf -t "$subpkgdir"/usr/share/fonts/$_fontname/

	cd "$subpkgdir"
	_install_conf "$srcdir"/fontconfig.conf 61-$_fontname-vf
}

_install_conf() {
	local src=$1
	local name=$2

	install -D -m644 "$src" usr/share/fontconfig/conf.avail/$name.conf
	mkdir -p etc/fonts/conf.d
	ln -s /usr/share/fontconfig/conf.avail/$name.conf etc/fonts/conf.d/
}

sha512sums="
7f71b34cce960bb5b90165505214d9effa7aa0b9e3ae3a7da37b900db54adbb30d1ff4b44f77c88fe0c7ddef45fc17ac6f05f08745fd26e1a298eeb61e6fddd3  Fira_Code_v6.2.zip
9125f4bbb486d57975fe0a5fa0a612d8fca80516cd6b39a7806754f3b683ee451d6e428d43e09e4f9ecf51a11a5b6bab562517539facaab0297127cdf8f79639  fontconfig.conf
"
